﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Character_Creator
{
    public class Skill
    {
        private string skillName;
        private string skillReference;
        private uint skillRanks;
        private int skillModifier;
        private int skillAbility;
        private int skillMiscMod;
        private bool isFavoredByClass;

        public string Name
        {
            get { return skillName; }
            private set { skillName = value; }
        }
        public string Reference
        {
            get { return skillReference; }
            private set { skillReference = value; }
        }
        public uint Ranks
        {
            get { return skillRanks; }
            private set { skillRanks = value; }
        }
        public int TotalBonus
        {
            get { return skillModifier; }
            private set { skillModifier = value; }
        }
        public int AbilityModifier
        {
            get { return skillAbility; }
            private set { skillAbility = value; }
        }
        public int MiscModifier
        {
            get { return skillMiscMod; }
            private set { skillMiscMod = value; }
        }
        public bool IsFavoredSkill
        {
            get { return isFavoredByClass; }
            private set { isFavoredByClass = value; }
        }

        /// <summary>
        /// Constructs a Skill. Use this version when passing skills for editor purposes.
        /// </summary>
        /// <param name="name">The name of the skill.</param>
        /// <param name="reference">The page reference of the skill description.</param>
        public Skill(string name, string reference)
        {
        }
        /// <summary>
        /// Constructs a skill. Use this version when passing skills for character purposes.
        /// </summary>
        /// <param name="name">The name of the skill.</param>
        /// <param name="reference">The page reference of the skill description.</param>
        /// <param name="ability">The ability modifier associated with this skill.</param>
        /// <param name="isFavored">Denotes whether or not the skill is a favored one for the class (adding a rank to a favored class skill adds +3 to the skill check)</param>
        public Skill(string name, string reference, int ability, bool isFavored)
        {
            SetSkillName(name);
            SetSkillAbilityModifier(ability);
            SetIsFavoredSkill(isFavored);
            SetSkillMiscModifier(0);
            SetSkillRanks(0);
            CalculateAndSetTotalBonus();
        }

        public override string ToString()
        {
            return Name;
        }

        public void SetSkillName(string name)
        {
            Name = name;
        }
        public void SetSkillPageReference(string reference)
        {
            Reference = reference;
        }
        public void SetSkillRanks(uint ranks)
        {
            Ranks = ranks;
        }
        public void SetSkillAbilityModifier(int abilityMod)
        {
            AbilityModifier = abilityMod;
        }
        public void SetSkillMiscModifier(int miscMod)
        {
            MiscModifier = miscMod; 
        }
        public void SetIsFavoredSkill(bool isFavored)
        {
            IsFavoredSkill = isFavored; 
        }
        public void CalculateAndSetTotalBonus()
        {
            TotalBonus = (int)(Ranks + AbilityModifier + MiscModifier + (int)((IsFavoredSkill) ? 3 : 0));
        }
    }
}
